package com.yc.login.web;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ResetInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String vcode = request.getParameter("vcode");
        Object resetVcode = request.getSession().getAttribute("resetVcode");
        if (vcode == null || vcode.equals(resetVcode) == false) {
            response.sendRedirect("/error.html");
            return false;
        }
        return true;
    }
}
